package ZoneId_Demo;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class ChronosUnitDemo {
    public static void main(String[] args) {
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime bir = LocalDateTime.of(2000,1,1,0,0,0);
        System.out.println(bir);


        System.out.println("相差的年" + ChronoUnit.YEARS.between(now,bir));
        System.out.println("相差的月" + ChronoUnit.MONTHS.between(now,bir));
        System.out.println("相差的周" + ChronoUnit.WEEKS.between(now,bir));
        System.out.println("相差的日" + ChronoUnit.DAYS.between(now,bir));
        System.out.println("相差的小时" + ChronoUnit.HOURS.between(now,bir));
        System.out.println("相差的分钟" + ChronoUnit.MINUTES.between(now,bir));
        System.out.println("相差的秒" + ChronoUnit.SECONDS.between(now,bir));
        System.out.println("相差的毫秒" + ChronoUnit.MILLIS.between(now,bir));
        System.out.println("相差的微秒" + ChronoUnit.MICROS.between(now,bir));
        System.out.println("相差的纳秒" + ChronoUnit.NANOS.between(now,bir));
        System.out.println("相差的半天" + ChronoUnit.HALF_DAYS.between(now,bir));
        System.out.println("相差的十年" + ChronoUnit.DECADES.between(now,bir));
        System.out.println("相差的世纪" + ChronoUnit.CENTURIES.between(now,bir));
        System.out.println("相差的千年" + ChronoUnit.MILLENNIA.between(now,bir));
        System.out.println("相差的纪元" + ChronoUnit.ERAS.between(now,bir));
    }
}
